﻿
/*============== simpleIRC - http://matthias.van-eeghem.com/ ==============*
 *                                                                         *
 *  File: Query.cs                                                         *
 *  Project: IRC.dll                                                       *
 *  Author(s): Matthias Van Eeghem <matthias@van-eeghem.com>               *
 *                                                                         *
 * ========================================================================*
 *                                                                         *
 *  This program is free software: you can redistribute it and/or modify   *
 *  it under the terms of the GNU General Public License as published by   *
 *  the Free Software Foundation, either version 3 of the License, or      *
 *  (at your option) any later version.                                    *
 *                                                                         *
 *  This program is distributed in the hope that it will be useful,        *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *  GNU General Public License for more details.                           *
 *                                                                         *
 *  You should have received a copy of the GNU General Public License      *
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 *                                                                         *
===========================================================================*/

namespace simpleIRC
{
    public class Query
    {
        // This property will hold the reference to the Server object
        // The server object stored is the server this query is on.
        public Server Server { get; private set; }
        public Logger Logger { get; private set; }

        // Holds all text that was said in a query window.
        public string Text { get; set; }
        // Holds the name of the query
        public string Name { get; set; }
        // This variable holds the query index
        public int Index { get; private set; }

        public Query(int serverIndex, string userName)
        {
            // Get the server object that is the querys parent and save it
            Server = Core.ServerList[serverIndex];

            Name = userName;
            Index = Core.QueryList.Count;

            // Add the query object to the QueryList
            Core.QueryList.Add(this);
            Core.LoggerList.Add(new Logger(Server.Hostname.ToLower(), userName));

            Logger = Core.LoggerList[(Core.LoggerList.Count - 1)];
        }

        /// <summary>
        /// This method removes the query (by setting the object to null)
        /// </summary>

        public void Remove()
        {
            Logger.Remove();
            Core.QueryList[Index] = null;
        }
    }
}